# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=pyew
pkgver=109.8eb3e49
pkgrel=4
groups=('blackarch' 'blackarch-malware')
pkgdesc='A python tool to analyse malware.'
arch=('any')
url='https://code.google.com/p/pyew/'
license=('GPL2')
depends=('distorm' 'python2' 'python2-capstone' 'python2-setuptools')
makedepends=('git')
source=("git+https://github.com/joxeankoret/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  for i in *.py ; do
    install -Dm 755 $i "$pkgdir/usr/share/$pkgname/$i"
  done

  install -Dm 755 pyew "$pkgdir/usr/share/$pkgname/$pkgname"

  for i in Elf anal contrib logo plugins scripts ; do
    install -dm 755 "$pkgdir/usr/share/$pkgname/$i"
    cp -a $i/* "$pkgdir/usr/share/$pkgname/$i/";
  done

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/pyew/LICENSE"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" ChangeLog AUTHORS \
    COPYING

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

